<?php /* Smarty version 2.6.18, created on 2015-09-01 18:40:16
         compiled from createCdk.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?> <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "top.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?> <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "left.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs"><script
	type="text/javascript">
	try {
		ace.settings.check('breadcrumbs', 'fixed')
	} catch (e) {
	}
</script>

<ul class="breadcrumb">
	<li><i class="icon-home home-icon"></i> <a
		href="index.php">首页</a></li>
</ul>
<!-- .breadcrumb --></div>

<div class="page-content">

						<div class="row">
							<div class="col-xs-12">
							<!--  
							<div class="alert alert-block alert-success">
   
									<button type="button" class="close" data-dismiss="alert">
										<i class="icon-remove"></i>
								</button>

									<i class="icon-hand-right"></i>温馨提示
									<strong class="green">
										因数据量较大,实时数据查询耗时较长,每查询一天的数据大约需要8秒,请您耐心等待。
									</strong>

						</div>
						-->
							
								<!-- PAGE CONTENT BEGINS -->
								
								<div class="row">
									<div class="col-sm-12">
										<div class="widget-box">
											<div class="widget-header header-color-blue2">生成cdk操作
												<h4 class="lighter smaller"></h4>
											</div>

											<div class="widget-body">
												<div class="widget-main padding-8">
						<form class="form-horizontal" role="form">
																	
									<center>
											
										<div class="form-group">
											<label class="col-sm-7 control-label no-padding-right" for="form-field-1"><strong>生成cdk(每生成1万cdk大约需要10秒)</strong></label>
											<span>  &nbsp;</span>
										</div>
										
										<table style="width:60%;"  id="sample-table-1" class="table table-striped table-bordered table-hover ">
										<thead>
											<tr>
												<th class="col-sm-1">类别</th>
												<th class="col-sm-1">条件</th>
						
											</tr>
										</thead>

										<tbody>
											<tr>
												<td style="width:50%;">
													<label class="col-sm-6 control-label no-padding-right" for="form-field-5">游    戏</label>	
												</td>
												<td>
													
													<div class="col-sm-3">
													<select id="selectGame">
													<option value="" >游    戏</option>
													<?php if ($this->_tpl_vars['selectGames']): ?> <?php $_from = $this->_tpl_vars['selectGames']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
													<?php if ($this->_tpl_vars['nowGame'] == $this->_tpl_vars['value']): ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
" selected><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php else: ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
"><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php endif; ?> <?php endforeach; endif; unset($_from); ?> <?php endif; ?>
												</select>
												</div>
												
												</td>
											</tr>
											<tr>
												<td>
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">渠    道</label>
												</td>
												<td>
													
											<div class="col-sm-3">
											<select id="channel">
												<option value="" id="selectChannel">渠   道</option>
												<?php if ($this->_tpl_vars['channel']): ?>
												<option value="<?php echo $this->_tpl_vars['channel']; ?>
" selected><?php echo $this->_tpl_vars['channel']; ?>
</option>
												<?php endif; ?> 
											</select>
											</div>
												</td>
											</tr>
											
											<tr>
												<th class="col-sm-4">
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">类    型</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="cdkType" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											<tr>
												<th class="col-sm-4">
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">礼包内容</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="giftContent" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											<tr>
												<th class="col-sm-4">
											<label class="col-sm-6 control-label no-padding-right" for="form-field-5">数		量</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="cdkNum" placeholder="" style="width:250px;"  class=" col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											<tr>
												<td class="col-sm-4">
											<label class="col-sm-6 control-label no-padding-right" for="form-field-5">开始时间</label>
												</td>
												<td class="col-sm-3">
										
										<div  class="input-group"><span  class="input-group-addon">
										 <i class="icon-calendar bigger-110"></i> </span> 
										 <input class="date-picker col-xs-3 col-sm-6" id="startTime"
												value="<?php echo $this->_tpl_vars['startDate']; ?>
" type="text" style="width:220px;" data-date-format="yyyy-mm-dd" /></div>
												</td>
											</tr>
											<td>
											<label class="col-sm-6 control-label no-padding-right" for="form-field-5">结束时间</label>
											</td>
											<td class="col-sm-3">
											<div class="input-group"><span class="input-group-addon"> 
											<i class="icon-calendar bigger-110"></i> </span> 
											<input class="date-picker col-xs-3 col-sm-6" id="endTime"
													value="<?php echo $this->_tpl_vars['endDate']; ?>
" type="text" style="width:220px;" data-date-format="yyyy-mm-dd" />
											</div>
												</td>
											</tr>
											
											<tr>
							
												<td colspan="2">
												<center>
													<button type="button" onclick = "createCdk();" class="btn btn-info btn-success">
																生成并下载cdk
													</button>
												</center>
												</td>
											</tr>
											
											<?php if ($this->_tpl_vars['errorMsg']): ?>
											<tr>
												<td style="color:red" colspan="2">
												<center>
													<?php echo $this->_tpl_vars['errorMsg']; ?>

												</center>
												</td>
											</tr>
											<?php endif; ?>
									
										</tbody>
										
											
									</table>
							
							
									<div class="form-group">
											<label class="col-sm-7 control-label no-padding-right" for="form-field-1"><strong>追加cdk(每追加1万cdk大约需要10秒)</strong></label>
											<span>  &nbsp;</span>
									</div>
										
										<table style="width:60%;"  id="sample-table-1" class="table table-striped table-bordered table-hover ">
										<thead>
											<tr>
												<th class="col-sm-1">类别</th>
												<th class="col-sm-1">条件</th>
						
											</tr>
										</thead>

										<tbody>
											<tr>
												<td style="width:50%;">
													<label class="col-sm-6 control-label no-padding-right" for="form-field-5">游    戏</label>	
												</td>
												<td>
													
													<div class="col-sm-3"><select id="selectGame2">
													<option value="" >游   戏</option>
													<?php if ($this->_tpl_vars['selectGames']): ?> <?php $_from = $this->_tpl_vars['selectGames']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
													<?php if ($this->_tpl_vars['nowGame'] == $this->_tpl_vars['value']): ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
" selected><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php else: ?>
													<option value="<?php echo $this->_tpl_vars['value']; ?>
"><?php echo $this->_tpl_vars['value']; ?>
</option>
													<?php endif; ?> <?php endforeach; endif; unset($_from); ?> <?php endif; ?>
												</select>
												</div>
												
												</td>
											</tr>
											<tr>
												<td>
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">渠    道</label>
												</td>
												<td>
													
											<div class="col-sm-3">
											<select id="channel2">
												<option value="" id="selectChannel2">渠    道 </option>
												<?php if ($this->_tpl_vars['channel']): ?>
												<option value="<?php echo $this->_tpl_vars['channel']; ?>
" selected><?php echo $this->_tpl_vars['channel']; ?>
</option>
												<?php endif; ?> 
											</select>
											</div>
												</td>
											</tr>
											
											<tr>
												<th class="col-sm-4">
												<label class="col-sm-6 control-label no-padding-right" for="form-field-5">类    型</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="cdkType2" placeholder="" style="width:250px;"  class="col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											<tr>
												<th class="col-sm-4">
											<label class="col-sm-6 control-label no-padding-right" for="form-field-5">数		量</label>
												</th>
												<th class="col-sm-6">
												<div class="col-sm-2">
													<input type="text" id="cdkNum2" placeholder="" style="width:250px;"  class=" col-xs-1 col-sm-1" />
												</div>
												</th>
											</tr>
											
											<tr>
											<td colspan="2">
												<div class="clearfix">
														<center>
															<button type="button" onclick = "addCdk();" class="btn btn-info btn-success">
																<!--<i class="icon-bolt"></i>-->
																追加并下载cdk
															</button>
														</center>
												</div>
											</td>
											</tr>
									
										</tbody>
							
									</table>
									
								
									
									
									
							</form>
							</div>
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->
				</div>
				</div>
				</div>

<!-- /.table-responsive --></div>
</div>
<!-- /.page-content --></div>
<!-- /.main-content -->
<script type="text/javascript">


	jQuery(function($) {
		$('.date-picker').datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});
/*
		$('[data-rel="tooltip"]').tooltip({
			placement : tooltip_placement
		});
		function tooltip_placement(context, source) {
			var $source = $(source);
			var $parent = $source.closest('table')
			var off1 = $parent.offset();
			var w1 = $parent.width();

			var off2 = $source.offset();
			var w2 = $source.width();

			if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2))
				return 'right';
			return 'left';
		}
*/		
	});

	function createCdk() {
		var game = $('#selectGame').val();
		var channel = $('#channel').val();
		var cdkType = $('#cdkType').val();
		var giftContent = $('#giftContent').val();
		var cdkNum = $('#cdkNum').val();
		var startTime = $('#startTime').val();
		var endTime = $('#endTime').val();
	
		if (!game  || !cdkType || !giftContent || !cdkNum) {
			alert('请将信息填写完整！');
		} else {
				url = "index.php?mod=Cdk&do=create&game="
					+ game
					+ "&channel="
					+ channel
					+ "&cdkType="
					+ cdkType
					+ "&giftContent="
					+ giftContent
					+ "&cdkNum="
					+ cdkNum
					+ "&startTime="
					+ startTime
					+ "&endTime="
					+ endTime;
				
			window.location.href = url;
		}
	}
	
	
	function addCdk() {
		var game = $('#selectGame2').val();
		var channel = $('#channel2').val();
		var cdkType = $('#cdkType2').val();
		var cdkNum = $('#cdkNum2').val();
	
		if (!game  || !cdkType  || !cdkNum) {
			alert('请将信息填写完整！');
		} else {
				url = "index.php?mod=Cdk&do=addCdk&game="
					+ game
					+ "&channel="
					+ channel
					+ "&cdkType="
					+ cdkType
					+ "&cdkNum="
					+ cdkNum;
				
			window.location.href = url;
		}
	}
	
	
	window.onload = function(){
	    var select = document.getElementById('selectGame');
	    var select2 = document.getElementById('selectGame2');
	    select.onchange = function(){
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame  option:selected").text();
	       var _tagNum = 1;
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					
					if(dataObj == null) {
						$("#platform").empty();
						$("#platform").append('<option value="" id="selectPlatform">平    台</option>');
						$("#channel").empty();
						$("#channel").append('<option value="" id="selectChannel">渠    道</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform").empty();
					$("#platform").append('<option value="" id="selectPlatform">平    台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
					
					var channel = dataObj.channel;
					$("#channel").empty();
					$("#channel").append('<option value="" id="selectChannel">渠    道</option>');
					for(var i=0;i<channel.length;i++){
						$("#channel").append("<option value='"+channel[i]+"' >"+channel[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	    
	    select2.onchange = function(){
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame2  option:selected").text();
	       var _tagNum = 1;
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					
					if(dataObj == null) {
						$("#platform").empty();
						$("#platform").append('<option value="" id="selectPlatform">平    台</option>');
						$("#channel2").empty();
						$("#channel2").append('<option value="" id="selectChannel">渠    道</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform").empty();
					$("#platform").append('<option value="" id="selectPlatform">平    台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
					
					var channel = dataObj.channel;
					$("#channel2").empty();
					$("#channel2").append('<option value="" id="selectChannel">渠    道</option>');
					for(var i=0;i<channel.length;i++){
						$("#channel2").append("<option value='"+channel[i]+"' >"+channel[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	    
	} 
	
</script>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
